<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=, initial-scale=1.0">
    <script src="https://cdn.bootcdn.net/ajax/libs/vue/2.6.11/vue.min.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/axios/0.19.2/axios.min.js"></script>
    <link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/element-ui/2.13.0/theme-chalk/index.css">
    <script src="https://cdn.bootcdn.net/ajax/libs/element-ui/2.13.0/index.js"></script>
    <title>自定义回复</title>
</head>
<body>
    <div id="app">
        <el-row>
            <el-col :span="24">
                <div class="grid-content bg-purple-dark">
                    <el-button size="medium" type="primary" @click="dialogFormVisible = true" icon="el-icon-circle-plus">添加</el-button>
                        <el-dialog title="添加回复" :visible.sync="dialogFormVisible">
                            <el-form :model="form">

                                <el-form-item label="触发方式" :label-width="formLabelWidth">
                                    <el-radio v-model="trigger" label="fullmatch">完全匹配</el-radio>
                                    <el-radio v-model="trigger" label="keyword">关键字匹配</el-radio>
                                    <el-radio v-model="trigger" label="rex">正则匹配</el-radio>
                                </el-form-item>

                                <el-form-item label="触发词" :label-width="formLabelWidth">
                                    <el-input v-model="form.word" autocomplete="off"></el-input>
                                </el-form-item>

                                <el-form-item label="回复" :label-width="formLabelWidth">
                                    <el-input v-model="form.reply" autocomplete="off"></el-input>
                                </el-form-item>

                                <el-upload
                                    class="upload-demo"
                                    action="{{ url_for('reply.call_action', action='upload') }}"
                                    :on-preview="handlePreview"
                                    :on-success="uploadSuccess"
                                    :on-error="uploadError"
                                    :on-remove="handleRemove"
                                    :before-remove="beforeRemove"
                                    multiple
                                    :limit="10"
                                    :on-exceed="handleExceed"
                                    :file-list="fileList">
                                    <el-button size="small" type="primary">上传图片或者音频</el-button>
                                    <div slot="tip" class="el-upload__tip">只能上传jpg/png/mp3文件</div>
                                </el-upload>
                                <p v-text="cqcode"></p>
                                <el-button size="mini" type="primary" @click="doCopy" >复制酷Q码</el-button>
                                <el-button size="mini" type="primary" @click="varDialogVisible = true" >查看变量</el-button>

                                <el-dialog title="变量一览" :visible.sync="varDialogVisible" append-to-body>
                                    <el-table :data="varData">
                                      <el-table-column prop="var" label="变量" width="200"></el-table-column>
                                      <el-table-column prop="desc" label="说明" width="200"></el-table-column>
                                      <el-table-column prop="operation" label="操作">
                                        <template slot-scope="scope">
                                            <el-button size="mini" type="primary" @click="copyVar(scope)">复制</el-button>
                                          </template>
                                      </el-table-column>
                                    </el-table>
                                  </el-dialog>

                            </el-form>
                            <div slot="footer" class="dialog-footer">
                            <el-button @click="dialogFormVisible = false">取 消</el-button>
                            <el-button type="primary" @click="add_rec()">确 定</el-button>
                            </div>
                        </el-dialog>
                    <el-button size="medium" type="primary" @click="refresh()" icon="el-icon-refresh">刷新</el-button>
                </div>
            </el-col>
        </el-row>
        <el-table :data="tableData" style="width: 100%">
            <el-table-column prop="trigger" label="触发方式" width="180"></el-table-column>
            <el-table-column prop="word" label="触发词" width="180"></el-table-column>
            <el-table-column prop="reply" label="回复" width="180"></el-table-column>
            <el-table-column prop="operation" label="操作">
                <template slot-scope="scope">
                    <el-button size="mini" type="primary">编辑</el-button>
                    <el-button size="mini" type="danger" @click="delete_rec(scope)" icon="el-icon-delete">删除</el-button>
                </template>
            </el-table-column>
        </el-table>
    </div>
</body>
<script src="{{ url_for('reply.staticfile',filename='show_reply.js') }}"></script>
<script src="{{ url_for('reply.staticfile',filename='vue-clipboard.js') }}"></script>
</html>